package javaLearning.异常;

/**
 * @author : K k
 * @date : 21:03 2020/9/13
 * finally优先级比catch高，若双方都捕捉异常则捕获finally
 * 若在catch和finally中都return，则返回的是finally中的return
 */
public class ExceptionDemo2 {
    public static void main(String[] args) {
       ExceptionDemo2 demo2=new ExceptionDemo2();
        System.out.println(demo2.action());
    }

    public int action(){
        try{
            int i=2/0;
        }catch (Exception e){
            //System.out.println(e.getMessage());
            //throw new IllegalArgumentException("参数错了");
            throw new RuntimeException("出错了");
            //return 1;
        }finally {
            //int i=2/0;
            System.out.println("我执行了");
            throw new IllegalArgumentException("参数错了");
            //throw new RuntimeException("出错了");
            //return;
            //return 2;
        }
    }
}
